package com.gpio;

import javax.jms.JMSException;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * @author ZJY
 * mq测试客户端程序
 */
public class MqTestClient {
	
	private static Logger logger = LogManager.getLogger(GPIOControlThread.class);

	public static void main(String[] args) throws JMSException {
//		logger.info("======================={}mq订阅服务器初始化开始=======================",DateTimeUtil.getCurrentDateTimeStr());
//		ConnectionFactory factory = new ActiveMQConnectionFactory(Config.MQ_USERNAME, Config.MQ_PASSWORD, Config.MQ_URL);
//		Connection connection = factory.createConnection();
//		connection.start();
//		logger.info("======================={}mq订阅服务器连接mq服务器成功=======================",DateTimeUtil.getCurrentDateTimeStr());
//		Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
//		Topic topic = session.createTopic(Config.MQ_TOPIC);
//
//		MessageProducer producer = session.createProducer(topic);
//		producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
//		
//		int count = 10;
//		ExecutorService executorService = Executors.newFixedThreadPool(3);
//		String xmlStr1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Message><MsgID>7f200a68f11e45a69ae7d3f8b63b5f5a</MsgID><MsgType>EQUIPMENT</MsgType><Version>2.0</Version><Provider>0001</Provider><EquipType>01</EquipType><EquipID>371502000000011008</EquipID><EquipIP>10.16.4.121</EquipIP><EquipPort>80</EquipPort><EquipName>合肥路与劲松三路路口电警北</EquipName><FaultLevel>2</FaultLevel><FaultType1L code=\"-1\"><FaultType2L code=\"1\"></FaultType2L><FaultType2L code=\"3\"></FaultType2L></FaultType1L><FaultDesc>电警相机镜头发生故障，无法正常聚焦</FaultDesc><FilePathes><FilePath type=\"1\">http://10.16.1.85:8080/picture/示例图片.JPG</FilePath><FilePath type=\"2\">http://10.16.1.85:8080/video/示例视频.MP4</FilePath></FilePathes><ChectTime>2016-04-18 13:14:27</ChectTime><FaultTime>2016-04-18 13:53:23</FaultTime><UploadTime>2016-04-18 14:53:41</UploadTime></Message>";
//		String xmlStr2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Message><MsgID>7f200a68f11e45a69ae7d3f8b63b5f5a</MsgID><MsgType>EQUIPMENT</MsgType><Version>2.0</Version><Provider>0001</Provider><EquipType>01</EquipType><EquipID>371502000000011007</EquipID><EquipIP>10.16.4.121</EquipIP><EquipPort>80</EquipPort><EquipName>合肥路与劲松三路路口电警北</EquipName><FaultLevel>2</FaultLevel><FaultType1L code=\"2\"><FaultType2L code=\"1\"></FaultType2L><FaultType2L code=\"3\"></FaultType2L></FaultType1L><FaultDesc>电警相机镜头发生故障，无法正常聚焦</FaultDesc><FilePathes><FilePath type=\"1\">http://10.16.1.85:8080/picture/示例图片.JPG</FilePath><FilePath type=\"2\">http://10.16.1.85:8080/video/示例视频.MP4</FilePath></FilePathes><ChectTime>2016-04-18 13:14:27</ChectTime><FaultTime>2016-04-18 13:53:23</FaultTime><UploadTime>2016-04-18 14:53:41</UploadTime></Message>";
//		String xmlStr3 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Message><MsgID>7f200a68f11e45a69ae7d3f8b63b5f5a</MsgID><MsgType>EQUIPMENT</MsgType><Version>2.0</Version><Provider>0001</Provider><EquipType>01</EquipType><EquipID>371502000000011001</EquipID><EquipIP>10.16.4.121</EquipIP><EquipPort>80</EquipPort><EquipName>合肥路与劲松三路路口电警北</EquipName><FaultLevel>2</FaultLevel><FaultType1L code=\"3\"><FaultType2L code=\"1\"></FaultType2L><FaultType2L code=\"3\"></FaultType2L></FaultType1L><FaultDesc>电警相机镜头发生故障，无法正常聚焦</FaultDesc><FilePathes><FilePath type=\"1\">http://10.16.1.85:8080/picture/示例图片.JPG</FilePath><FilePath type=\"2\">http://10.16.1.85:8080/video/示例视频.MP4</FilePath></FilePathes><ChectTime>2016-04-18 13:14:27</ChectTime><FaultTime>2016-04-18 13:53:23</FaultTime><UploadTime>2016-04-18 14:53:41</UploadTime></Message>";
//		while (count > 0) {
//			executorService.execute(new TestProduceThread(session, producer, xmlStr1));
//			executorService.execute(new TestProduceThread(session, producer, xmlStr2));
//			executorService.execute(new TestProduceThread(session, producer, xmlStr3));
//			try {
//				Thread.sleep(5*1000L);
//			} catch (InterruptedException e) {
//				e.printStackTrace();
//			}
//			count--;
//		}
//		session.close();
//		connection.stop();
//		connection.close();
	}
}